package com.smart.lab;

import android.Manifest;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import com.google.android.material.bottomnavigation.BottomNavigationView;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.smart.lab.databinding.ActivityMainBinding;
import com.yanzhenjie.permission.Action;
import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.Rationale;
import com.yanzhenjie.permission.RequestExecutor;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        BottomNavigationView navView = findViewById(R.id.nav_view);
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications,R.id.navigation_mine)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
//        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(binding.navView, navController);

//        requestPermission();
    }


        /**
         * 动态申请  (电话/位置/存储)
         */
//        @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
//        private void requestPermission() {
//            AndPermission.with(this)
//                    .permission(Manifest.permission.CAMERA,
//                            Manifest.permission.READ_EXTERNAL_STORAGE)
//                    .rationale(new Rationale() {
//                        @Override
//                        public void showRationale(Context context, List<String> permissions, RequestExecutor executor) {
//                            executor.execute();
//                        }
//                    })
//                    .onGranted(new Action() {
//                        @Override
//                        public void onAction(List<String> permissions) {
////                            Log.e(TAG, "用户给权限");
//                        }
//                    })
//                    .onDenied(new Action() {
//                        @Override
//                        public void onAction(List<String> permissions) {
//                            if (AndPermission.hasAlwaysDeniedPermission(MainActivity.this, permissions)) {
//                                // 打开权限设置页
//                                AndPermission.permissionSetting(MainActivity.this).execute();
//                                return;
//                            }
////                            Log.e(TAG, "用户拒绝权限");
//                        }
//                    })
//                    .start();
//        }


}